'use strict';

stareal
    .controller("DetailController", function ($rootScope,$scope,$http,$compile,$interval,$stateParams,$location,$anchorScroll,$api, $sce, base64, $state, $alert, localStorageService,FileUploader,$lazyLoader) {
        $scope.current = $stateParams.good_id;
        if($stateParams.app==1){
            $scope.BackStatus=true;
            $scope.dowload_appStatus=true;
        }
        $scope.closedDowload=function(){
            $scope.dowload_appStatus=false;
        }
        $scope.longitude=localStorageService.get('longitude');//当前的位置
        $scope.latitude=localStorageService.get('latitude');//当前的位置
        $scope.sort=2;
        $scope.selectReplyId=0;
        $scope.sacn_more=true;
        $scope.text='';
        $scope.sharUrl='https://test.djx.m.opentickets.cn/?&#/'; // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致'
        $scope.iSore='';
        var h=$(window).height()-2.6*parseFloat(document.documentElement.style.fontSize)+"px";
        $("#wrapper_container").height(h);
        if($scope.longitude0==''||$scope.longitude0==undefined||$scope.longitude0==null) {
            var  map= new AMap.Map('position_center');
            //实例化城市
            var geolocation = null;
            map.plugin('AMap.Geolocation', function (){
                geolocation = new AMap.Geolocation({
                    enableHighAccuracy: true,//是否使用高精度定位，默认:true
                    timeout: 10000,          //超过10秒后停止定位，默认：无穷大
                    maximumAge: 0,           //定位结果缓存0毫秒，默认：0
                    convert: true,           //自动偏移坐标，偏移后的坐标为高德坐标，默认：true
                    showButton: true,        //显示定位按钮，默认：true
                    buttonPosition: 'LB',    //定位按钮停靠位置，默认：'LB'，左下角
                    buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
                    showMarker: true,        //定位成功后在定位到的位置显示点标记，默认：true
                    showCircle: true,        //定位成功后用圆圈表示定位精度范围，默认：true
                    panToLocation: true,     //定位成功后将定位到的位置作为地图中心点，默认：true
                    zoomToAccuracy:true      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
                });
                map.addControl(geolocation);
                geolocation.getCurrentPosition(function(status,result){
                    if(status=='complete'){
                        localStorageService.set('longitude',result.position.lng);
                        localStorageService.set('latitude',result.position.lat);
                    }else{
                        $alert.show('定位失败！');
                    }

                });
            });
        }
        $api.get("app/good/findById", {id: $stateParams.good_id}, true)
            .then(function (ret) {
                var good = ret.data;
                localStorageService.set("goodDetail", good)
                // good.detail = $sce.trustAsHtml(base64.decode(good.detail));
                good.detail = $sce.trustAsHtml(good.detail);
                $scope.good = good;
                $scope.title = good.name;
                $scope.site_title = $scope.good.site_title;
                $scope.thumb = $scope.good.thumb;
                $scope.seat = good.seat_thumb;  //座位图
                $scope.favor = $scope.good.favor;//收藏\
                $scope.star = $scope.good.star;
                $scope.goodType = $scope.good.good_type;
                $scope.is_coupon = $scope.good.is_coupon;//是否可以使用优惠券
                // $alert.show($scope.title);
                $scope.getShare();
                if ($scope.star) {
                    $scope.star = good.star.split('.')
                }
                if (good.state == '售票中') {
                    $scope.shop_bg = '';
                    $scope.gbn = '立即购票';
                    $scope.gf = 1;
                }
                if (good.state == '预售中') {
                    $scope.shop_bg = '';
                    $scope.gbn = '立即购票';
                    $scope.gf = 1;
                }
                if (good.state == '扫尾票') {
                    $scope.shop_bg = '';
                    $scope.gbn = '立即购票';
                    $scope.gf = 1;
                }
                if (good.state == '即将开票') {
                    $scope.good.sold = 0;
                    if (good.appRegistered == 1) {
                        $scope.gbn = '已预订';
                        $scope.shop_bg = 'subscribe';
                        return false;
                    }
                    $scope.shop_bg = 'subscribe';
                    $scope.gbn = '立即预定';
                    $scope.gf = 1;
                }

                if (good.state == '演出结束') {
                    $scope.shop_bg = 'disable';
                    $scope.gbn = good.state;
                    $scope.gf = 0;
                }

            },function(err){
                $alert.show(err);
            });
        $scope.gotoViewEdit=function(){
            var  rs = "main.detail-" + JSON.stringify({good_id: $stateParams.good_id});
            var token=localStorageService.get('token');
            var isbind = localStorageService.get('isbind');
            var openID = localStorageService.get('openid');
            if(isbind!=1&&openID!=''){
                localStorageService.set('cleartoken',token);
                location.href = "#/main/register/"+encodeURIComponent(rs);
                localStorageService.set('token','');
                return false
            }
            if (!localStorageService.get('token')) {
                var  rs = "main.detail-" + JSON.stringify({good_id: $stateParams.good_id});
                var ua = window.navigator.userAgent.toLowerCase();
                if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                    location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?" +
                        "appid=wxda73ac8ac7af1261&" +
                        "redirect_uri=http%3A%2F%2Ftest.djx.m.opentickets.cn%2Foauth%2Findex" +
                        "&response_type=code&scope=snsapi_userinfo&state="+encodeURIComponent(rs)+"&connect_redirect=1#wechat_redirect";
                } else {
                    location.href = "#/main/login/"+encodeURIComponent(rs);
                }
                return false;
            }
            $state.go('main.viewwangeditor',{id:'',viewshowname:$scope.title},true);
        }
        $scope.bartotla=function(count){
            // console.log(count);
            if(count==undefined||count==''){
                var bar=(count*10).toFixed(0)/100;
                $scope.barstyle = {
                    "width":'0rem' ,
                }
            }else{
                var bar=(count*10).toFixed(0)/100;
                $scope.barstyle = {
                    "width":bar*2.75+'rem' ,
                }
            }

            return $scope.barstyle;
        }
        //获取 售票平台app/view/seller
        $api.get("app/view/seller",{goodid:$stateParams.good_id},true)
            .then(function (ret) {
                var data=ret.data;
                for(var i=0;i<data.length;i++){
                    if(i<3){
                        data[i].moreRankShowable=true;
                    }else{
                        data[i].moreRankShowable=false;
                    }
                }
                $scope.sellerLists=data;
                $scope.sellerLists.length=ret.data.length;
            },function(err){
                $alert.show(err);
            });
        //票务
        //查看10
       $scope.showdailogImg=function(){
           $scope.showdailogImgstatus=true;
       }
       $scope.hidedailogImg=function(){
           $scope.showdailogImgstatus=false;
       }
        $scope.scan_more=function(){
            for(var i=3;i<$scope.sellerLists.length;i++){
                $scope.sellerLists[i].moreRankShowable=true;
            }
            $scope.sacn_more=false;
        }
        //收起
        $scope.Takeup=function(){
            for(var i=3;i<$scope.sellerLists.length;i++){
                $scope.sellerLists[i].moreRankShowable=false;
            }
            $scope.sacn_more=true;
        }
        $scope.goSellerPiao=function(url){
            // console.log($scope.selectUrl);
            window.open(url);
        }
        $scope.IsPraisedetail = function (commentid,Index,num,from,event){
            var  rs = "main.detail-" + JSON.stringify({good_id: $stateParams.good_id});
            var token=localStorageService.get('token');
            var isbind = localStorageService.get('isbind');
            var openID = localStorageService.get('openid');
            if(isbind!=1&&openID!=''){
                localStorageService.set('cleartoken',token);
                location.href = "#/main/register/"+encodeURIComponent(rs);
                localStorageService.set('token','');
                return false
            }
            if (!localStorageService.get('token')) {
                var  rs = "main.detail-" + JSON.stringify({good_id: $stateParams.good_id});
                var ua = window.navigator.userAgent.toLowerCase();
                if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                    //测试redirect_uri
                    location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?" +
                        "appid=wxda73ac8ac7af1261&" +
                        "redirect_uri=http%3A%2F%2Ftest.djx.m.opentickets.cn%2Foauth%2Findex" +
                        "&response_type=code&scope=snsapi_userinfo&state="+encodeURIComponent(rs)+"&connect_redirect=1#wechat_redirect";
                } else {
                    location.href = "#/main/login/"+encodeURIComponent(rs);
                }
                return false;
            }
            event.stopPropagation()//阻止冒泡
            $api.post("app/comment/praise", {comment_id:commentid}, true)
                .then(function (ret) {
                        $scope.reviews.items[Index].is_praise = !$scope.reviews.items[Index].is_praise;
                        $scope.reviews.items[Index].like = parseInt(ret.praise)+num;
                },function (err) {
                    $alert.show(err)
                })
        }
        $scope.wantScan=function(index,num,event){
            event.stopPropagation()//阻止冒泡
            var  rs = "main.detail-" + JSON.stringify({good_id: $stateParams.good_id});
            var token=localStorageService.get('token');
            var isbind = localStorageService.get('isbind');
            var openID = localStorageService.get('openid');
            if(isbind!=1&&openID!=''){
                localStorageService.set('cleartoken',token);
                location.href = "#/main/register/"+encodeURIComponent(rs);
                localStorageService.set('token','');
                return false
            }
            if (!localStorageService.get('token')) {
                var  rs = "main.detail-" + JSON.stringify({good_id: $stateParams.good_id});
                var ua = window.navigator.userAgent.toLowerCase();
                if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                    // 正式地址
                    location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?" +
                        "appid=wxda73ac8ac7af1261&" +
                        "redirect_uri=http%3A%2F%2Ftest.djx.m.opentickets.cn%2Foauth%2Findex" +
                        "&response_type=code&scope=snsapi_userinfo&state="+encodeURIComponent(rs)+"&connect_redirect=1#wechat_redirect";
                } else {
                    location.href = "#/main/login/"+encodeURIComponent(rs);
                }
                return false;
            }
            if($scope.iSore==''||$scope.iSore==undefined||$scope.iSore==null){
                $alert.show('请评分!');
                return false;
            }
            $api.post("app/good/wantpeople",{goodid:$stateParams.good_id,star:$scope.iSore},true)
                .then(function (ret) {
                   if(ret.follow==1){
                       if(index==1){
                           $scope.showdailogstatus=false;
                           $alert.show("加入想看成功!");
                           location.reload();
                       }else if(index==2){
                           $state.go('main.viewwangeditor',{},true);
                       }

                   }else{
                       $alert.show(ret.message);
                   }
                });
        }
        //当前加active
        $scope.isActive = function (s) {
            return $scope.current == s
        }
        $scope.LeftLength=function () {
            if($scope.text!=''&&$scope.text!=null&&$scope.text!=undefined){
                $scope.colorComentStatus=true;
                if($scope.text.length>150){
                    var value = $scope.text.substring(0, 150);
                    $scope.text= value;
                }
                return $scope.text.length;
            }else{
                $scope.colorComentStatus=false;
                return 0;
            }
        }
        $scope.getDistance=function(long,lat){
            if(long==undefined||long==''||long==null||lat==undefined||lat==''||lat==null||$scope.latitude==''||$scope.latitude==null||$scope.latitude==undefined){
                return '暂无'
            }else{
                var p1 = [long, lat];
                var p0 = [ $scope.longitude,$scope.latitude];
                var dis = AMap.GeometryUtil.distance(p1, p0); //米
                return (dis/1000).toFixed(2)+'km' ;
            }

        }

        //获取头像
        if (localStorageService.get('token')!='') {
            $api.get("app/login/userinfo/retrieve", null, true)
                .then(function (ret) {
                    $scope.user = ret.data;
                })
        }
        //获取评论
        var refresh=function(sort){
            $scope.reviews = new $lazyLoader("app/comment/goodComments",{good_id:$stateParams.good_id,sort:sort},true);
            $scope.reviews.nextPage();
        }
        refresh(2);
        //切换
        $scope.switchComent=function(index){
            $scope.sort=index;
            refresh(index);
        }
        //跳转写评论
        $scope.write = function () {
            var  rs = "main.detail-" + JSON.stringify({good_id: $stateParams.good_id});
            var token=localStorageService.get('token');
            var isbind = localStorageService.get('isbind');
            var openID = localStorageService.get('openid');
            var ua = window.navigator.userAgent.toLowerCase();
            if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                if (isbind != 1 && openID != '') {
                    localStorageService.set('cleartoken', token);
                    location.href = "#/main/register/" + encodeURIComponent(rs);
                    localStorageService.set('token', '');
                    return false
                }
            }
            if (!localStorageService.get('token')) {
                var  rs = "main.detail-" + JSON.stringify({good_id: $stateParams.good_id});
                var ua = window.navigator.userAgent.toLowerCase();
                if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                    // 正式地址
                    location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?" +
                        "appid=wxda73ac8ac7af1261&" +
                        "redirect_uri=http%3A%2F%2Ftest.djx.m.opentickets.cn%2Foauth%2Findex" +
                        "&response_type=code&scope=snsapi_userinfo&state="+encodeURIComponent(rs)+"&connect_redirect=1#wechat_redirect";
                } else {
                    location.href = "#/main/login/"+encodeURIComponent(rs);
                }
                return false;
            }
            $state.go('main.write_reviews', {good_id: $scope.current});
        }
        //写评论
        var oStar = document.getElementById("star");
        var items = oStar.getElementsByTagName("li");
        var oUl = oStar.getElementsByTagName("ul")[0];
        var i =0;
        var iScore = 0;
        $scope.halfStar=function (x,event) {
            event.stopPropagation()//阻止冒泡
            x = parseInt(x) - 1;
            var tem = -1;
            for(var i = 0; i < items.length; i++) {
                if(x > i*2) {
                    items[i].className='full';
                } else {
                    if(tem == -1) {
                        tem = i;
                    }
                    items[i].className='';
                }
            }
            if(x == parseInt(tem)*2) {
                items[tem].className='half';
            }
            $scope.iSore=parseInt(x)+1+'.0'
        }
        $scope.showdailogstatus=false;
        $scope.showsdailog=function(){
            var  rs = "main.detail-" + JSON.stringify({good_id: $stateParams.good_id});
            var token=localStorageService.get('token');
            var isbind = localStorageService.get('isbind');
            var openID = localStorageService.get('openid');
            if(isbind!=1&&openID!=''){
                localStorageService.set('cleartoken',token);
                location.href = "#/main/register/"+encodeURIComponent(rs);
                localStorageService.set('token','');
                return false
            }
            if (!localStorageService.get('token')) {
                var  rs = "main.detail-" + JSON.stringify({good_id: $stateParams.good_id});
                var ua = window.navigator.userAgent.toLowerCase();
                if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                    // 正式地址
                    location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?" +
                        "appid=wxda73ac8ac7af1261&" +
                        "redirect_uri=http%3A%2F%2Ftest.djx.m.opentickets.cn%2Foauth%2Findex" +
                        "&response_type=code&scope=snsapi_userinfo&state="+encodeURIComponent(rs)+"&connect_redirect=1#wechat_redirect";
                } else {
                    location.href = "#/main/login/"+encodeURIComponent(rs);
                }
                return false;
            }
            $scope.showdailogstatus=true;
        }
        $scope.hidesdailog=function(){
            $scope.showdailogstatus=false;
            $scope.iSore='';
            for(var i = 0; i < items.length; i++) {
                    items[i].className='';
            }
        }
        //举报 操作
        $scope.showoperationdailog=function(ID,  useID,conts){
            var  rs = "main.detail-" + JSON.stringify({good_id: $stateParams.good_id});
            var token=localStorageService.get('token');
            var isbind = localStorageService.get('isbind');
            var openID = localStorageService.get('openid');
            if(isbind!=1&&openID!=''){
                localStorageService.set('cleartoken',token);
                location.href = "#/main/register/"+encodeURIComponent(rs);
                localStorageService.set('token','');
                return false
            }
            if (!localStorageService.get('token')) {
                var  rs = "main.detail-" + JSON.stringify({good_id: $stateParams.good_id});
                var ua = window.navigator.userAgent.toLowerCase();
                if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                    // 正式地址
                    location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?" +
                        "appid=wxda73ac8ac7af1261&" +
                        "redirect_uri=http%3A%2F%2Ftest.djx.m.opentickets.cn%2Foauth%2Findex" +
                        "&response_type=code&scope=snsapi_userinfo&state="+encodeURIComponent(rs)+"&connect_redirect=1#wechat_redirect";
                } else {
                    location.href = "#/main/login/"+encodeURIComponent(rs);
                }
                return false;
            }
            if($scope.user.id==useID){
                $scope.deleteStatus=true;
            }else{
                $scope.deleteStatus=false;
            }
            $scope.selectReplyId=ID;
            $scope.selectReplycontent=conts;
            $scope.showoperationstatus=true;
        }
        $scope.hideoperationdailog=function(){
            $scope.showoperationstatus=false;
        }
        //回复 ui-sref="main.allreply({comment_id:review.id})"
         $scope.operationreply=function(event){
             event.stopPropagation()//阻止冒泡
            $state.go('main.allreply',{comment_id:$scope.selectReplyId},true);
         }
         //删除
        $scope.operationdelet=function(event){
            event.stopPropagation()//阻止冒泡
            $api.post("app/viewcomment/del", {
                comment_id: $scope.selectReplyId,
                type: 1
            }, true)
                .then(function (ret) {
                    $alert.show("删除成功!");
                   location.reload();
                }, function (err) {
                    $alert.show(err);

                })
        }
         //举报  app/viewcomment/report  type=1
        $scope.operationReport=function(content,event){
            event.stopPropagation()//阻止冒泡
            $api.post("app/viewcomment/report", {
                comment_id: $scope.selectReplyId,
                type: 1,
                content:content
            }, true)
                .then(function (ret) {
                    $alert.show("举报成功!");
                    $scope.operationReportdailogstatus=false;
                }, function (err) {
                    $alert.show(err);

                })
        }
        //举报弹窗
        $scope.showReportdailog=function(event){
            event.stopPropagation()//阻止冒泡
            $scope.operationReportdailogstatus=true;
            $scope.showoperationstatus=false;
        }
        $scope.hideReportdailog=function(){
            $scope.operationReportdailogstatus=false;
        }
        //收藏
        $scope.collect = function (GoodId) {
            var  rs = "main.detail-" + JSON.stringify({good_id: $stateParams.good_id});
            var token=localStorageService.get('token');
            var isbind = localStorageService.get('isbind');
            var openID = localStorageService.get('openid');
            if(isbind!=1&&openID!=''){
                localStorageService.set('cleartoken',token);
                location.href = "#/main/register/"+encodeURIComponent(rs);
                localStorageService.set('token','');
                return false
            }
            if (!localStorageService.get('token')) {
                var  rs = "main.detail-" + JSON.stringify({good_id: $stateParams.good_id});
                var ua = window.navigator.userAgent.toLowerCase();
                if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                    // 正式地址
                    location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?" +
                        "appid=wxda73ac8ac7af1261&" +
                        "redirect_uri=http%3A%2F%2Ftest.djx.m.opentickets.cn%2Foauth%2Findex" +
                        "&response_type=code&scope=snsapi_userinfo&state="+encodeURIComponent(rs)+"&connect_redirect=1#wechat_redirect";
                } else {
                    location.href = "#/main/login/"+encodeURIComponent(rs);
                }
                return false;
            }
            $api.post("app/favor/create", {good_id: GoodId}, true)
                .then(function (ret) {
                    if ($scope.favor == 0) {
                        $scope.favor = 1;
                        $scope.good.watchpeople+=1;
                        $alert.show("收藏成功")
                    } else {
                        $scope.favor = 0;
                        $scope.good.watchpeople-=1;
                        $alert.show("取消收藏")
                    }
                })
        }
        //弹出编辑框
        $scope.tanViewCommen=function(){
            var  rs = "main.detail-" + JSON.stringify({good_id: $stateParams.good_id});
            var token=localStorageService.get('token');
            var isbind = localStorageService.get('isbind');
            var openID = localStorageService.get('openid');
            if(isbind!=1&&openID!=''){
                localStorageService.set('cleartoken',token);
                location.href = "#/main/register/"+encodeURIComponent(rs);
                localStorageService.set('token','');
                return false
            }
            if (!localStorageService.get('token')) {
                var  rs = "main.detail-" + JSON.stringify({good_id: $stateParams.good_id});
                var ua = window.navigator.userAgent.toLowerCase();
                if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                    // 正式地址
                    location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?" +
                        "appid=wxda73ac8ac7af1261&" +
                        "redirect_uri=http%3A%2F%2Ftest.djx.m.opentickets.cn%2Foauth%2Findex" +
                        "&response_type=code&scope=snsapi_userinfo&state="+encodeURIComponent(rs)+"&connect_redirect=1#wechat_redirect";
                } else {
                    location.href = "#/main/login/"+encodeURIComponent(rs);
                }
                return false;
            }
            $("#viewComments_send").show();
        }
        //取消评论编辑
        $scope.cancelviewCommment=function(){
            $("#editComment").val("");
            $scope.text='';
            $("#viewComments_send").hide();
        }
        //确定发表
        $scope.sendviewCommment=function(){
            if($("#editComment").val()==''){
                $alert.show("请填写发表的内容！");
                return false;
            }
            if($("#editComment").val().length<=3){
                $alert.show("评论内容请多于3个字！");
                return false;
            }
            $("#viewComments_send").hide();
            $api.post("app/comment/create",{
                good_id:  $scope.current,
                content:$("#editComment").val(),
                // star:scor
            },true).then(function (ret) {
                $alert.show("发表成功！");
                location.reload();
            },function(err){
                $alert.show(err);
                $("#editComment").val('');
            })

        }
        $scope.stopPropagation = function (event) {
            event.stopPropagation()//阻止冒泡
        }

        //分享
        //微信分享http://192.168.1.4:9090/oauth/getSignature
        $scope.getShare=function(){
            $api.get("app/share/getSignature", {url: window.location.href.split('#')[0]})
                .then(function (ret) {
                    if (ret) {
                        var data = ret.data;
                        wx.config({
                            debug: false,
                            appId: data.appid,
                            timestamp: data.timestamp,
                            nonceStr: data.nonceStr,
                            signature: data.signature,
                            jsApiList: [
                                'onMenuShareTimeline',
                                'onMenuShareAppMessage',
                                'onMenuShareQQ',
                                // 'onMenuShareWeibo',
                                'onMenuShareQZone'
                            ]
                        });
                        wx.ready(function () {
                            //分享到朋友圈
                            wx.onMenuShareTimeline({
                                title: $scope.title, // 分享标题
                                desc: '我在独角秀分享了一个不错的演出！', // 分享描述
                                link: $scope.sharUrl+'main/detail/good/'+$stateParams.good_id+'/1', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                                imgUrl:  $scope.thumb, // 分享图标
                                success: function () {
                                    // 用户确认分享后执行的回调函数
                                    //alert('你好');
                                    $alert.show("分享成功");
                                },
                                cancel: function () {
                                    // 用户取消分享后执行的回调函数
                                    // alert('你好....');
                                }
                            });
                            //分享给朋友
                            wx.onMenuShareAppMessage({
                                title: $scope.title, // 分享标题
                                desc: '我在独角秀分享了一个不错的演出！', // 分享描述
                                link: $scope.sharUrl+'main/detail/good/'+$stateParams.good_id+'/1', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                                imgUrl:  $scope.thumb, // 分享图标
                                type: '', // 分享类型,music、video或link，不填默认为link
                                dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                                success: function () {
// 用户确认分享后执行的回调函数
                                    $alert.show("分享成功");
                                    // alert('你好....');
                                },
                                cancel: function () {
// 用户取消分享后执行的回调函数
                                }
                            });
                            wx.onMenuShareQQ({
                                title: $scope.title, // 分享标题
                                desc: '我在独角秀分享了一个不错的演出！', // 分享描述
                                link: $scope.sharUrl+'main/detail/good/'+$stateParams.good_id+'/1', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                                imgUrl:  $scope.thumb, // 分享图标
                                success: function () {
// 用户确认分享后执行的回调函数
                                    $alert.show("分享成功");
                                },
                                cancel: function () {
// 用户取消分享后执行的回调函数
                                }
                            });
                            wx.onMenuShareQZone({
                                title: $scope.title, // 分享标题
                                desc: '我在独角秀分享了一个不错的演出！', // 分享描述
                                link: $scope.sharUrl+'main/detail/good/'+$stateParams.good_id+'/1', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                                imgUrl:  $scope.thumb, // 分享图标
                                success: function () {
// 用户确认分享后执行的回调函数
                                    $alert.show("分享成功");
                                },
                                cancel: function () {
// 用户取消分享后执行的回调函数
                                }
                            });
                        });
                        wx.error(function (res) {
                            //console.log(res);
                            //alert("微信分享接口配置失败");
                        });
                    }
                })
        }
})





